﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace Alfa.Common.ValidationRules {
	public class StringMaxLengthValidationRule : ValidationRuleBase {
		public StringMaxLengthValidationRule( ) { }

		public long Max { get; set; }

		public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
			if (value is string) {
				if (Max < ((string)value).Length) {
					return this.ParseError(false, Messages.PleaseEnterANumberLowerThan + Max.ToString( ) + ".");
				}
			}

			return this.ParseError(true, null);
		}
	}
}
